<?php

class NewsAndEvents extends CWidget {

    public $lang='th';
    
    public function run() {
        $newsList = News::getNewslist(1, 5);
        ?>
        <div class="panel panel-success">
            <!-- Default panel contents -->
            <div class="panel-heading"><img src="images/001_12.png"> <b>News and Events</b></div>
            <!-- Table -->
            <table class="table table-hover">
                <?php 
                foreach ($newsList as $news) { ?>
                <tr><td><b><?= $news['CreateDate'] ?></b>
                        <?= $this->lang == 'en'?$news['TitleEN']:$news['TitleTH'] ?>
                        <a href="index.php?lang=<?= $this->lang ?>&r=News/Detail&id=<?= $news['NewsID'] ?>">
                            Read More »
                        </a>
                    </td></tr>
                <?php } ?>
                <tr><td style="text-align: right !important">
                        <a href="index.php?lang=<?= $this->lang ?>&r=News/List"><?= $this->lang == 'en'?'View All News':'View All News' ?>
                    </a></td></tr>
            </table>
        </div>
        <?php
    }
}
?>